{include title="添加管理员" keywords="" description=""  file='../application/admin/view/layout/header.html' /}
<body>
<div class="x-body">
	<form class="layui-form" action="{:url('admin/admin/adminAdd')}">
		{:token()}
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="x-red">*</span>登录名：</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" placeholder="用户名" name="username">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label"><span class="x-red">*</span>初始密码：</label>
		<div class="layui-input-block">
			<input type="password" class="layui-input"  placeholder="密码" name="password">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="x-red">*</span>确认密码：</label>
		<div class="layui-input-block">
			<input type="password" class="layui-input" name="password" placeholder="确认密码" datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致！">
		</div>
	</div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" placeholder="姓名" datatype="*"
                   name="nickname">
        </div>
    </div>
	<div class="layui-form-item">
		<label class="layui-form-label">手机：</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" placeholder="手机号" name="phone">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">邮箱：</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" placeholder="邮箱地址" name="email">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="x-red">*</span>角色：</label>
		<div class="layui-input-block">
			<select class="layui-input" name="role_id">
				{foreach $role as $v}
				<option value="{$v['id']}">{$v['name']}</option>
				{/foreach}
			</select>
			</span> </div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">备注：</label>
		<div class="layui-input-block">
			<textarea name="remark" class="layui-input" placeholder="说点什么...100个字符以内" ></textarea>
		</div>
	</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal">提交</button>
			</div>
		</div>
	</form>
</div>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
	//前端验证
    var check = $("form").Validform({
        tiptype: function (msg, o) {
            if (o.type == 3) {layer.msg(msg, {icon: 2});}
        },
        ajaxPost: true,
        callback: function (data) {
            if(data.status=='y'){
                layer.msg(data.info, {icon: 1});
                setTimeout(function(){
                    parent.location.reload();
                },1000);
            }else{
                $("[name=__token__]").val(data.token);
            }
        }
    });
    check.addRule([
        {ele: "[name='username']", datatype: /^\w{4,18}$/, nullmsg: '请填写用户名', errormsg: "用户名在4至18位之间的数字、字母、下划线"},
        {ele: "[name='password']", datatype: /[a-z\d#@!~%^&*]{6,18}/i, nullmsg: '请填写密码', errormsg: "密码在6到18位之间的数字、字母、英文符号"},
        {ele: "[name='nickname']", datatype: /^.{0,10}$/,  errormsg: "姓名10个字以内"},
        {ele: "[name='phone']", datatype: /^(1[34578]\d{9})$/, nullmsg: '请输入手机号', errormsg: "手机号格式错误"},
        {ele: "[name='email']", datatype: /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/, nullmsg: '请输入邮箱地址', errormsg: "邮箱地址格式错误"},
        {ele: "[name='role']", datatype: /^\d+$/, nullmsg: '请输选择用户角色', errormsg: "用户角色错误"},
        {ele: "[name='remark']", datatype: /^.{0,100}$/,  errormsg: "验证码为4位数字字母"}
    ]);
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>